package com.bdmc.smokesensor.controller;

import java.util.Map;

import com.bdmc.smokesensor.Utils.Msg;
import com.bdmc.smokesensor.Utils.ResultUtil;
import com.bdmc.smokesensor.services.Sys_LogService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/log",method = RequestMethod.POST)
public class Sys_LogController extends BaseController{
    @Autowired
    private Sys_LogService _logSvs;

        /** * 查询日志信息 * */
        @RequestMapping(value = "/list")
        public Msg list(@RequestBody Map<String, Object> map) {
            int page =Integer.valueOf(map.get("page").toString());
            int rows = Integer.valueOf(Integer.valueOf(map.get("rows").toString()));
            String pg = map.get("pg").toString();
            String loginName = map.get("loginName").toString();
            Sort s = new Sort(Direction.DESC,"joinDate");
            return ResultUtil.success(_logSvs.findAllByPage(pg,loginName,PageRequest.of(page, rows,s)));
        }
}